<?php

namespace Modules\Demo\Http\Requests;

use Illuminate\Foundation\Http\FormRequest as Request;

class DemoRequest extends Request
{
    /**
     * @return array
     */
    public function rules(): array
    {
        return [
            'name' => 'required',
//            'one_file' => [
//                'required',
//                function ($attribute, $value, $fail) {
//                    $headers = get_headers($value[0]['response']['path'], true);
//                    $mime = $headers['Content-Type'] ?? '';
//                    if (!str_contains($mime, 'application/pdf')) {
//                        $fail('只能上传pdf文件');
//                    }
//                }
//            ],
        ];
    }


    /**
     *
     * @return array
     */
    public function messages(): array
    {
        return [
            'file.required' => '请上传文件',
        ];
    }
}
